package com.e.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ZhangSanServlet
 */
public class LogServlet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LogServlet1() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//response.getWriter().append("Served at: ").append(request.getContextPath());
		response.setCharacterEncoding("UTF-8");//设置输出内容的编码格式
		response.setContentType("text/html");//设置输出的文件类型
		PrintWriter out = response.getWriter();
		out.println("<!DOCTYPE html>");
		out.println("<HTML>");
		out.println("<HEAD><meta charset='UTF-8'><title>登录界面</title></HEAD>");
		out.println("<BODY>登录成功！！！<br/></BODY>");
				out.println("</HTML>");
				out.flush();
				out.close();// 关闭输出流
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		String className=request.getParameter("className");
		String sex=request.getParameter("sex");
		if (className.equals("1902")&&sex.equals("男")) {
			request.getRequestDispatcher("SuccessServlet").forward(request, response);
		}else {
			response.sendRedirect("FailServlet");
		}
	}

}
